#include <linux/unistd.h>
#include <sys/syscall.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define __NR_begin_freeze 317
#define __NR_freeze 318

extern void initializeList(void);
extern void insert_white_list(unsigned long d);
extern int white_listed(unsigned long d);
extern int init_log(void);
extern int log_event(unsigned int unique_id, char * buffer, int newFile, int regFile);

struct file_data {
  unsigned int unique_id;
  int newFile;
  int regFile;
  char path_name[128];
};

struct file_data dst;
_syscall0(long, begin_freeze);
_syscall1(long, freeze, struct file_data *, dst);

int main() {
  initializeList();
  init_log();
  begin_freeze();

  /* Repeatedly call the freeze syscall.
     Check to see if the file has already
     been modified by calling the white_listed
     method. If it hasn't, then add it to the
     list.  Call log event with the file's info.
  */
  while (1) {
    if (freeze(&dst)) {
      if (white_listed(dst.unique_id) == 0) {
	insert_white_list(dst.unique_id);
	log_event(dst.unique_id, dst.path_name, dst.newFile, dst.regFile);
	printf("%u\t%d\t%d\t%s\n", dst.unique_id, dst.newFile, dst.regFile, dst.path_name);
      }
    }    
  }
}
